<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Authenticate {

	function Authenticate()
	{
	//maybe some day!
	}

	function is_authenticated() {

		$CI =& get_instance();
		$CI->load->library('session');
		if (!($author_id = $CI->session->userdata('author_id'))) {
			return false;
		}

		if (!($hash = $CI->session->userdata('hash'))) {
			return false;
		}

		$CI->load->database('default', TRUE);
		$CI->db->where('author_id', $author_id);
		$CI->db->where('hash', $hash);
		$query = $CI->db->get('author');

		if ($query->num_rows() > 0) {
			return $query->row_array();
		} else {
			return false;
		}
	}
}

?>
